package ui;

import java.awt.Dimension;
import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SpringLayout;

public class GamePlayerView extends JPanel {
	
    private JLabel Player1, Player2, VS, player1Score, dash, player2Score;

    public GamePlayerView() {
        init();
    }

    public void init() {
        setBorder(BorderFactory.createTitledBorder("Spelers: "));
        setLayout(new SpringLayout());

        Player1 = new JLabel("Speler 1", JLabel.CENTER);
        Player1.setPreferredSize(new Dimension(140, 40));
        
        VS = new JLabel("VS", JLabel.CENTER);
        VS.setPreferredSize(new Dimension(20, 40));
        
        Player2 = new JLabel("Speler 2", JLabel.CENTER);
        Player2.setPreferredSize(new Dimension(140, 40));
        
        player1Score = new JLabel("0", JLabel.CENTER);
        player1Score.setPreferredSize(new Dimension(150, 40));
        player1Score.setFont(new Font("Arial",Font.BOLD,22));
        
        dash = new JLabel("-", JLabel.CENTER);
        dash.setPreferredSize(new Dimension(20, 40));
        
        player2Score = new JLabel("0", JLabel.CENTER);
        player2Score.setPreferredSize(new Dimension(150, 40));
        player2Score.setFont(new Font("Arial",Font.BOLD,22));
        
        add(Player1);
        add(VS);
        add(Player2);
        
        add(player1Score);
        add(dash);
        add(player2Score);

        SpringUtilities.makeCompactGrid(this,
        2, 3,       //rows, cols
        4, 4,       //initX, initY
        4, 4);      //xPad, yPad
    }

    public void setPlayerOne(String string){
        Player1.setText(string);
    }

    public void setPlayerTwo(String string){
        Player2.setText(string);
    }
    
    public void setCurrentPlayer(String player) {
        if(Player1.getText().equals(player)) {
            Player1.setFont(new Font("Arial",Font.BOLD,14));
            Player2.setFont(null);
        } else {
            Player1.setFont(null);
            Player2.setFont(new Font("Arial",Font.BOLD,14));
        }
    }
    
    public void setPlayer1Score(int score) {
        player1Score.setText(Integer.toString(score));
    }
    
    public void setPlayer2Score(int score) {
        player2Score.setText(Integer.toString(score));
    }
}
